# This is a sample Python script.
import time

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

from selenium import webdriver
from selenium.common import exceptions
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://mail.163.com/?from=404')
driver.maximize_window()
driver.implicitly_wait(30)

iframe = driver.find_element(By.XPATH,'//*[@id="loginDiv"]/iframe')
iframe_id = iframe.get_attribute('id')
print('//*[@id="'+iframe_id+'"]')
driver.switch_to_frame(iframe_id)
email = driver.find_element(By.NAME, 'email')
email.send_keys('1233@qq.com')
driver.switch_to_parent_frame()
driver.switch_to_default_content()
# def exception():
#     try:
#         email = driver.find_element(By.NAME, 'email')
#         email.send_keys('1233@qq.com')
#         print('存在该元素')
#         return True
#     except exceptions.NoSuchElementException:
#         print('不存在该元素')
#         return
# exception()
time.sleep(5)
driver.close()